using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
using System.Drawing;

namespace Rapier.Kodachi.Core.Actions
{
    public class Display : Action
    {
        #region Constructor
        public Display(Plugin plugin)
            : base(plugin, "Rapier.CorePlugin.Display", "Display", "Displays the item text with all enabled Notifier plugins.")
        {
            GetImage = delegate() { return System.Drawing.SystemIcons.Information.ToBitmap(); };
        }
        #endregion

        #region Action Members
        public override bool IsValidDirect(Item directItem)
        {
            return directItem.Properties.ContainsKey("Text");
        }

        public override void Execute(Item[] directItems, Item[] indirectItems)
        {
            foreach (Item directItem in directItems)
            {
                NotificationPackage package = new NotificationPackage();
                if (directItem.Properties.ContainsKey("Text"))
                    package.Message = directItem.Properties["Text"].ToString();
                else
                    package.Message = directItem.Description;

                if (directItem.Image != null)
                    package.Image = directItem.Image;

                package.Caption = directItem.Name;

                Plugin.Host.Notify(package);
            }
        }
        #endregion
    }
}
